<?php

namespace app\health\validate;

class CartValidate extends BaseValidate
{
    protected $rule =   [
        'id'             => 'require',
        'ids'            => 'require|array|min:1',
        'goods_id'       => 'require',
        'goods_attr_id'  => 'require',
        'number.require' => 'require|min:1'
    ];

    protected $message  =   [
        'goods_id.require'      => '请选择商品ID',
        'goods_attr_id.require' => '请选择规格ID',
        'number.require'        => '请选择购买数量',
        'number.min'            => '购买数量最小为1',
        'id.require'            => '请选择购物车id',
        'ids.require'           => '请选择要删除的商品',
        'ids.array'             => '非法参数',
        'ids.min'               => '最少选择一个商品',
    ];

    // 场景验证
    protected $scene = [
        'add'    => ['goods_id', 'goods_attr_id', 'number'],
        'edit'   => ['id', 'number'],
        'delete' => ['ids']
    ];
}
